package com.grass.p019lv.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.bean.DateBean;
import java.util.ArrayList;
import java.util.List;

/* renamed from: com.grass.lv.adapter.AdapterCalendar */
public class AdapterCalendar extends BaseAdapter {
    DateBean dateBean;
    Context mContext;
    List<DateBean> mList;
    DateBean newDate;
    DateBean oldDate;

    public long getItemId(int i) {
        return (long) i;
    }

    public AdapterCalendar(Context context, List<DateBean> list, DateBean dateBean2) {
        if (list == null) {
            this.mList = new ArrayList();
        } else {
            this.mList = list;
        }
        this.mContext = context;
        this.dateBean = dateBean2;
        this.newDate = dateBean2;
        this.oldDate = new DateBean(2019, 1, 1);
    }

    public void setList(List<DateBean> list) {
        if (list != null) {
            this.mList = list;
            notifyDataSetChanged();
        }
    }

    public DateBean setIndex(int i) {
        int sum = this.mList.get(i).getSum();
        int sum2 = this.newDate.getSum();
        int sum3 = this.oldDate.getSum();
        if (sum > sum2 || sum < sum3) {
            return null;
        }
        this.dateBean = this.mList.get(i);
        notifyDataSetChanged();
        return this.dateBean;
    }

    public DateBean getIndex() {
        return this.dateBean;
    }

    public int getCount() {
        return this.mList.size();
    }

    public DateBean getItem(int i) {
        return this.mList.get(i);
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (view == null) {
            view = LayoutInflater.from(this.mContext).inflate(R.layout.item_calendar, viewGroup, false);
            viewHolder = new ViewHolder();
            viewHolder.tv_name = (TextView) view.findViewById(R.id.tv_name);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        DateBean dateBean2 = this.mList.get(i);
        int sum = dateBean2.getSum();
        int sum2 = this.newDate.getSum();
        int sum3 = this.oldDate.getSum();
        if (sum > sum2 || sum < sum3) {
            viewHolder.tv_name.setBackground(null);
            viewHolder.tv_name.setTextColor(Color.parseColor("#A3A3A3"));
        } else {
            DateBean dateBean3 = this.dateBean;
            if (dateBean3 != null && dateBean3.year == dateBean2.year && this.dateBean.mouth == dateBean2.mouth && this.dateBean.date == dateBean2.date) {
                viewHolder.tv_name.setBackground(this.mContext.getResources().getDrawable(R.drawable.shape_bg_calendar_item));
                viewHolder.tv_name.setTextColor(Color.parseColor("#0C1021"));
            } else {
                viewHolder.tv_name.setTextColor(this.mContext.getResources().getColor(R.color.white));
                viewHolder.tv_name.setBackground(null);
            }
        }
        TextView textView = viewHolder.tv_name;
        textView.setText(this.mList.get(i).date + "");
        return view;
    }

    /* renamed from: com.grass.lv.adapter.AdapterCalendar$ViewHolder */
    class ViewHolder {
        TextView tv_name;

        ViewHolder() {
        }
    }
}
